// Copyright (c) Microsoft Corporation.  All rights reserved.

#include "stdafx.h"
#include "D3D10ShaderReflectionType.h"
#include "D3D10ShaderReflectionType.h"

using namespace msclr::interop;
using namespace Microsoft::WindowsAPICodePack::DirectX::Direct3D10;

ShaderTypeDescription^ ShaderReflectionType::GetDescription()
{
    ShaderTypeDescription^ desc = gcnew ShaderTypeDescription();
    CommonUtils::VerifyResult(GetInterface<ID3D10ShaderReflectionType>()->GetDesc(desc->nativeObject.Get()));
    return desc;
}

ShaderReflectionType^ ShaderReflectionType::GetMemberTypeByIndex(UInt32 index)
{
    ID3D10ShaderReflectionType* returnValue = GetInterface<ID3D10ShaderReflectionType>()->GetMemberTypeByIndex(static_cast<UINT>(index));
    return returnValue == NULL ? nullptr : gcnew ShaderReflectionType(returnValue);
}

ShaderReflectionType^ ShaderReflectionType::GetMemberTypeByName(String^ name)
{
    marshal_context^ context = gcnew marshal_context();
    ID3D10ShaderReflectionType* returnValue = GetInterface<ID3D10ShaderReflectionType>()->GetMemberTypeByName(context->marshal_as<const char*>(name));
    return returnValue == NULL ? nullptr : gcnew ShaderReflectionType(returnValue);
}

String^ ShaderReflectionType::GetMemberTypeName(UInt32 index)
{
    LPCSTR returnValue = GetInterface<ID3D10ShaderReflectionType>()->GetMemberTypeName(static_cast<UINT>(index));
    return returnValue == NULL ? nullptr : gcnew String(returnValue);
}

